package com.chengwt.dao.impl;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.chengwt.entity.Document;
import com.chengwt.entity.TrainType;
import com.chengwt.entity.UserGroup;
import com.chengwt.util.HibernateUtil;

public class DucumentTrainTypeTest {
	public static void main(String args[]){
		Session session =HibernateUtil.getSession();
		Transaction tx = session.beginTransaction();
		
		try {
			TrainType tt = new TrainType();
			tt.setTrainTypeName("KY-01");
			
			TrainType tt1 = new TrainType();
			tt.setTrainTypeName("KY-02");
			
			Document d1 = new Document();
			d1.setDocumentName("MoveTrain");
			
			Document d2 = new Document();
			d2.setDocumentName("MoveTrain12");
			
		
			tt.getDocumentSet().add(d1);
			tt1.getDocumentSet().add(d2);
			
			d1.getTraintypeSet().add(tt);
			d2.getTraintypeSet().add(tt1);
			
			session.save(tt);
			tx.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
